package com.yanqu.road.server.cmd.grandchild;

import com.yanqu.road.pb.grandchild.GrandChildProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.grandchild.GrandChildMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;

@Cmd(code = CrossProtocol.C_GRAND_CHILD_GET_IMPERIAL_EXAM_RESULT, desc = "获取科举考试结果")
public class CrossGetExamResultCmd extends CrossCommand {

    private long userId;
    private String examNo;
    private int type;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        GrandChildProto.ExamResultRewardReqMsg reqMsg = GrandChildProto.ExamResultRewardReqMsg.parseFrom(packet.getBytes());
        examNo = reqMsg.getNo();
        type = reqMsg.getType();
        userId = packet.getPlayerId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        ret = GrandChildMgr.getExamResult(serverId, userId, Long.valueOf(examNo), type);
    }

    @Override
    public void sendData() {
        if (ret != 0) {
            // 不返回也没事，不改了
        }
    }
}
